package xuanke;

import java.io.*;

public class Test implements Serializable{
    public static void main(String[] args) throws IOException{
        Lessons gaoshu = new Lessons(1, "高等数学", "101教室", "Mon-08:00");
        Lessons wuli = new Lessons(2, "大学物理", "102教室", "Mon-13:00");
        Lessons yingyu = new Lessons(3, "雅思英语", "201教室", "Wed-08:00");
        Lessons xiandai = new Lessons(4, "线性代数", "202教室", "Wed-13:00");
        Lessons lisan = new Lessons(5, "离散数学", "301教室", "Fir-08:00");
        Lessons shuju = new Lessons(5, "数据科学", "302教室", "Fir-08:00");
        Lessons Python = new Lessons(7, "Python", "401教室", "Mon-13:00");
        Lessons C = new Lessons(8, "C++   ", "400教室", "Wed-13:00");
        Lessons Java = new Lessons(9, "Java  ", "400教室", "Fri-13:00");

        Teachers dong=new Teachers("0001","董老师",'女', new Lessons[]{gaoshu,xiandai});
        Teachers lv=new Teachers("0002","吕老师",'男',new Lessons[]{wuli});
        Teachers li=new Teachers("0003","李老师",'男',new Lessons[]{yingyu});
        Teachers fang=new Teachers("0004","方老师",'女',new Lessons[]{lisan,C});
        Teachers wang=new Teachers("004","刘老师",'男',new Lessons[]{shuju,Python});
        Teachers zhang=new Teachers("0006","张老师",'男',new Lessons[]{Java});

        gaoshu.setTeacher(dong);
        xiandai.setTeacher(dong);
        wuli.setTeacher(lv);
        yingyu.setTeacher(li);
        lisan.setTeacher(fang);
        C.setTeacher(fang);
        shuju.setTeacher(wang);
        Python.setTeacher(wang);
        Java.setTeacher(zhang);

        Lessons sIn1[]=new Lessons[]{shuju,lisan,C};
        Lessons sIn2[]=new Lessons[]{wuli,xiandai,lisan,Java};
        Lessons sIn3[]=new Lessons[]{gaoshu,wuli,yingyu,Python,C};
        Students sOut1=new Students();
        Students sOut2=new Students();
        Students sOut3=new Students();

        Students Stu1=new Students("202001","张三",'男',sIn1,2020);
        Students Stu2=new Students("202101","李四",'男',sIn2,2021);
        Students Stu3=new Students("202201","王五",'女',sIn3,2022);

        FileOutputStream in = new FileOutputStream("/Users/xiaozhaohong/Library/Mobile Documents/com~apple~CloudDocs/大学/课程/2.1-2.1Java技术及应用/experiment-6.1/Text.txt");
        ObjectOutputStream in1 = new ObjectOutputStream(in);
        in1.writeObject(Stu1);
        in1.writeObject(Stu2);
        in1.writeObject(Stu3);

        FileInputStream out=new FileInputStream("/Users/xiaozhaohong/Library/Mobile Documents/com~apple~CloudDocs/大学/课程/2.1-2.1Java技术及应用/experiment-6.1/Text.txt");
        ObjectInputStream out1 = new ObjectInputStream(out);
        try {
            sOut1= (Students)out1.readObject();
            sOut2= (Students)out1.readObject();
            sOut3= (Students)out1.readObject();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        sOut1.Tuike(C);
        sOut2.Tuike(wuli);
        sOut3.Tuike(yingyu);
        sOut3.Tuike(wuli);

        System.out.println(sOut1.toString());
        for(int i = 0; i<sOut1.lessons.length; i++){
            System.out.println(sOut1.lessons[i].toString());
        }

        System.out.println("\n"+sOut2.toString());
        for(int i = 0; i<sOut2.lessons.length; i++){
            System.out.println(sOut2.lessons[i].toString());
        }

        System.out.println("\n"+sOut3.toString());
        for(int i = 0; i<sOut3.lessons.length; i++){
            System.out.println(sOut3.lessons[i].toString());
        }

    }
}